﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Reporting.WinForms;

using Willson.JsbManager.Bll;
using Willson.JsbManager.BllEntity;
using Willson.JsbManager.Comm;

namespace Willson.JsbManager.UI
{
    public partial class XTCompanyJdPrintForm : Willson.JsbManager.UI.BaseForm
    {
        public XTCompanyJdPrintForm()
        {
            InitializeComponent();
        }

        private void XTCompanyJdPrintForm_Load(object sender, EventArgs e)
        {
            List<string> list = BLLFactory<BLLComm>.Instance.GetEmployeeList();

            IEnumerator<string> ator = list.GetEnumerator();

            while (ator.MoveNext())
            {
                cbx_employee.Items.Add(ator.Current.ToString());
            }
        }

        private void bt_1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(comboBox_year.Text))
            {
                MessageUtil.ShowWarning("请选择[年]");
                return;
            }

            if (string.IsNullOrEmpty(comboBox_jd.Text))
            {
                MessageUtil.ShowWarning("请选择[季度]");
                return;
            }

            if (string.IsNullOrEmpty(cbx_employee.Text))
            {
                MessageUtil.ShowWarning("请选择[联系人]");
                return;
            }
            
            
            PrintDataSet ds = new PrintDataSet();

            IEnumerator<BECompanyJdPrint> ator = BLLFactory<BLLCompanyJdPrint>.Instance.PrintJd(Convert.ToInt32(comboBox_year.Text), Convert.ToInt32(comboBox_jd.Text)).GetEnumerator();

            DataRow objRow;

            while (ator.MoveNext())
            {
                objRow = ds.Tables["Company_Jd_print"].NewRow();

                objRow["Company_name"] = ator.Current.m_Company_name;
                objRow["User_code_1"] = ator.Current.m_User_code_1;
                objRow["User_code_2"] = ator.Current.m_User_code_2;
                objRow["User_code_3"] = ator.Current.m_User_code_3;
                objRow["User_code_4"] = ator.Current.m_User_code_4;
                objRow["User_code_5"] = ator.Current.m_User_code_5;
                objRow["User_code_6"] = ator.Current.m_User_code_6;
                objRow["Sn_jh_1"] = ator.Current.m_Sn_jh_1;
                objRow["Sn_jh_2"] = ator.Current.m_Sn_jh_2;
                objRow["Sn_jh_3"] = ator.Current.m_Sn_jh_3;
                objRow["Sn_jh_4"] = ator.Current.m_Sn_jh_4;
                objRow["Sn_jh_5"] = ator.Current.m_Sn_jh_5;
                objRow["Sn_jh_6"] = ator.Current.m_Sn_jh_6;
                objRow["Sn_ysl_1"] = ator.Current.m_Sn_ysl_1;
                objRow["Sn_ysl_2"] = ator.Current.m_Sn_ysl_2;
                objRow["Sn_ysl_3"] = ator.Current.m_Sn_ysl_3;
                objRow["Sn_ysl_4"] = ator.Current.m_Sn_ysl_4;
                objRow["Sn_ysl_5"] = ator.Current.m_Sn_ysl_5;
                objRow["Sn_ysl_6"] = ator.Current.m_Sn_ysl_6;
                objRow["Bq_jh_1"] = ator.Current.m_Bq_jh_1;
                objRow["Bq_jh_2"] = ator.Current.m_Bq_jh_2;
                objRow["Bq_jh_3"] = ator.Current.m_Bq_jh_3;
                objRow["Bq_jh_4"] = ator.Current.m_Bq_jh_4;
                objRow["Bq_jh_5"] = ator.Current.m_Bq_jh_5;
                objRow["Bq_jh_6"] = ator.Current.m_Bq_jh_6;

                ds.Tables["Company_Jd_print"].Rows.Add(objRow);
            }

            List<ReportParameter> listPara = new List<ReportParameter>();

            ReportParameter para1 = new ReportParameter("TopTitle", string.Format("{0}年{1}季度用水计划量通知单", comboBox_year.Text, comboBox_jd.Text));
            ReportParameter para2 = new ReportParameter("Date", dateTimePicker.Text);
            ReportParameter para3 = new ReportParameter("Lxr", cbx_employee.Text);

            listPara.Add(para1);
            listPara.Add(para2);
            listPara.Add(para3);



            XTPrintViewForm form = new XTPrintViewForm();
            form.Bind(ds, "Company_Jd_print", "Willson.JsbManager.UI.CompanyJdJhPrint.rdlc", "PrintDataSet_Company_Jd_print", listPara);
            form.ShowDialog();
        }

        private void bt2_Click(object sender, EventArgs e)
        {

            PrintDataSet ds = new PrintDataSet();
            
            IEnumerator<BECompanyLetterPrint> ator = BLLFactory<BLLCompanyJdPrint>.Instance.GetCompanyLetterPrintInfoList().GetEnumerator();

            DataRow objRow;

            while (ator.MoveNext())
            {
                objRow = ds.Tables["CompanyLetterPrint"].NewRow();

                objRow["PostCode"] = ator.Current.m_PostCode;
                objRow["Address"] = ator.Current.m_Address;
                objRow["Sjr"] = ator.Current.m_Sjr;

                ds.Tables["CompanyLetterPrint"].Rows.Add(objRow);
            }

            XTPrintViewForm form = new XTPrintViewForm();
            form.Bind(ds, "CompanyLetterPrint", "Willson.JsbManager.UI.CompanyLetterPrint.rdlc", "PrintDataSet_CompanyLetterPrint", null);
            form.ShowDialog();

        }
    }
}
